﻿/**************************************************************************
创建时间:	2019/9/1 13:01:02    
作	  者:	张存
邮 	  箱:	zhangcunliang@126.com

Copyright (c) zhcun.cn

描	述：
记	录：
***************************************************************************/
using ASmile.Com;
using ASmile.Win.Controls;
using System;
using ASmile.Win.Extend;

namespace ASmile.Win
{
    /// <summary>
    /// 公共的comboxGrid
    /// </summary>
    public static class ComboxGridEx
    {
        /// <summary>
        /// 初始化 公共字典 的ComboxGrid
        /// </summary>
        public static ComboxGridArgs SetDict(this ComboxGrid coBoxGrid, EditText txt, string caption, Func<string, object> GetDataHandle)
        {
            var arg = new ComboxGridArgs
            {
                TxtBox = txt,
                RetrunTagField = "DictCode",
                ReturnTextField = "DictValue",
                GetDataSourceHandle = GetDataHandle,
                IsSendTabKey = true,
                Columns = new ComboxGridColumn[]
                {
                    new ComboxGridColumn("DictValue",caption),
                    new ComboxGridColumn("DictCode","键值",false)
                }
            };
            coBoxGrid.InitArgs(arg);
            return arg;
        }
        /// <summary>
        /// 初始化 公共字典 的ComboxGrid
        /// </summary>
        public static ComboxGridArgs SetDict(this ComboxGrid coBoxGrid, EditText txt, string caption, EmDictType dictType)
        {
            return SetDict(coBoxGrid, txt, caption,
                (serVal) => DictHelper.GetDicts(dictType));
        }
        /// <summary>
        /// 初始化ComboxGrid , dictType:EmDictType
        /// </summary>
        public static ComboxGridArgs SetDict(this FrmBase frm, EditText txt, string caption, EmDictType dictType)
        {
            return SetDict(frm.CoBoxGrid, txt, caption, dictType);
        }
    }
}